﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace ChannelVN.Cached.Entity
{
    [DataContract]
    public class PageSetting
    {
        [DataMember]
        public string CacheClientName { get; set; }
        [DataMember]
        public PageSettingItem[] PageSettingItems { get; set; }

        public PageSettingItem this[string cacheName]
        {
            get
            {
                var count = PageSettingItems.Length;
                for (var i = 0; i < count; i++)
                {
                    if (cacheName == PageSettingItems[i].Name)
                    {
                        return PageSettingItems[i];
                    }
                }
                return null;
            }
        }

        public PageSettingItem GetPageSettingByPageFile(string pageFile)
        {
            var count = PageSettingItems.Length;
            for (var i = 0; i < count; i++)
            {
                if (pageFile.ToLower() == PageSettingItems[i].PageFile.ToLower())
                {
                    return PageSettingItems[i];
                }
            }
            return null;
        }
    }
}
